
import { Column, Entity, JoinColumn, ManyToOne, OneToMany,  PrimaryGeneratedColumn } from 'typeorm';
import { CommonEntity } from "./common.entity";
import { MajorEntity } from './major.entity';
import { GradeEntity } from './grade.entity';
import { SysDept } from './framework/system/SysDept';
import { TeacherEntity } from './teacher.entity';
import { TeamEntity } from './team.entity';
import { TeacherVolunteerTeamEntity } from './teacherVolunteerTeam.entity';
@Entity('group', {
    comment: '分组信息表',
    schema: "public"
})
export class GroupEntity extends CommonEntity{
	@PrimaryGeneratedColumn({ type: 'integer', name: 'group_id', comment: '分组ID' })
	 groupId: number;

	@Column({ type: 'character varying', name: 'major_ids', default: null, comment: '分组专业ID' })
	 majorIds: string;

	@Column({ type: 'character varying', name: 'teacher_ids', default: null, comment: '分组教师ID' })
	 teacherIds: string;

	@Column({ type: 'character varying', name: 'group_name', default: null, comment: '分组名称' })
	 groupName: string;

	@Column({ type: 'integer', name: 'team_max', default: null, comment: '队伍最大人数' })
	 teamMax: number;

	@Column({ type: 'integer', name: 'teacher_max', default: null, comment: '教师最大人数' })
	 teacherMax: number;

	@Column({ type: 'timestamp without time zone', name: 'start_time', default: null, comment: '开始时间' })
	 startTime: string;

	@Column({ type: 'timestamp without time zone', name: 'end_time', default: null, comment: '结束时间' })
	 endTime: string;

	@Column({ type: 'character varying', name: 'remark', default: null, comment: '备注' })
	 remark: string;

	@Column({ type: 'character', name: 'status', default: '0', comment: '状态（0正常 1停用）' })
	 status: string;

	@Column({ type: 'character', name: 'del_flag', default: '0', comment: '删除标志（0代表存在 1代表删除）' })
	 delFlag: string;

   @Column({type:'integer',name:'dept_id',default:null,comment:'院系ID'})
   deptId:number;

   @Column({type:'integer',name:'grade_id',default:null,comment:'年级ID'})
   gradeId:number;

   @ManyToOne(() => SysDept, (sysDept) => sysDept.groups)
   @JoinColumn({ name: 'dept_id', referencedColumnName: 'deptId' })
   dept: SysDept;

   @ManyToOne(() => GradeEntity, (gradeEntity) => gradeEntity.groups)
   @JoinColumn({ name: 'grade_id', referencedColumnName: 'gradeId' })
   grade: GradeEntity;

   @OneToMany(() => MajorEntity, (majorEntity) => majorEntity.group)
   majors: MajorEntity[];
   
   @OneToMany(() => TeacherEntity, (teacherEntity) => teacherEntity.groups)
   teachers: TeacherEntity[];

   @OneToMany(() => TeamEntity, (teamEntity) => teamEntity.group)
   teams: TeamEntity[];

   @OneToMany(() => TeacherVolunteerTeamEntity, (teacherVolunteerTeamEntity) => teacherVolunteerTeamEntity.group)
   teacherVolunteers: TeacherVolunteerTeamEntity[];

}
